  <?php echo $header;?>
  <script type="text/javascript"><!--
        function filter() {
                url = 'index.php?route=Mart_Crm/goods_group_2&token=<?php echo $token; ?>';

                var filter_date_start = $('input[name=\'filter_date_start\']').attr('value');

                if (filter_date_start) {
                        url += '&filter_date_start=' + encodeURIComponent(filter_date_start);
                }

                var filter_date_end = $('input[name=\'filter_date_end\']').attr('value');

                if (filter_date_end) {
                        url += '&filter_date_end=' + encodeURIComponent(filter_date_end);
                }

                location = url;
        }
                //--></script> 

                <script type="text/javascript"><!--
                $(document).ready(function() {
                    $('#date-start').datepicker({dateFormat: 'yy-mm-dd'});

                    $('#date-end').datepicker({dateFormat: 'yy-mm-dd'});
                });
                //--></script> 
 <?php
    
    $str_data1 = "[['Task', 'Goods manage']";
    $str_data = "";
    $name = "";
    $total = "";
    if($rows != "")
    {
        foreach ($rows as $result)  
        {
                $str_data = $str_data.", ['".$result['name']."', ".$result['amount']."]";
                $total += $result['amount'];
        }
    }
    $name = $str_data1.$str_data."]";
    
?>
<style type="text/css">
        .table
        {
            border-collapse: collapse;
                border: 1px solid #00CCCC;
        }

        .td
        {
            border-collapse: collapse;
           border: 1px solid #00CCCC;
        }
</style>
  <div id="content">

      
      
      <div class="box">
          <div class="heading">
              <h1 align="center"><img src="view/image/report.png" alt="" /><?php echo $heading_title; ?></h1>
              <div class="buttons">
                  <a align="center" onclick="window.open('<?php echo $print; ?>', '_blank')" class="button"><?php echo $button_export_pdf; ?></a>
              </div>
               <div class="buttons">
                  <a align="center" onclick="window.open('<?php echo $export_excel; ?>', '_blank')" class="button"><?php echo $button_export_excel; ?></a>
              </div>
          </div>
          <div class="content">
              
              
              
              
              <table class="form">
        <tr>
          <td><?php echo $entry_date_start; ?>
            <input type="text" name="filter_date_start" value="<?php echo $filter_date_start; ?>" id="date-start" size="12" /></td>
          <td><?php echo $entry_date_end; ?>
            <input type="text" name="filter_date_end" value="<?php echo $filter_date_end; ?>" id="date-end" size="12" /></td>
        
          <td style="text-align: right;"><a onclick="filter();" class="button"><?php echo $button_display; ?></a></td>
        </tr>
      </table>

              <?php if ($rows) { ?>
              <div align=center class="reportChartContainer"> 
                  <script type="text/javascript" src="https://www.google.com/jsapi"></script>
                <script type="text/javascript">
                google.load("visualization", "1", {packages:["corechart"]});
                google.setOnLoadCallback(drawChart);
                function drawChart() {
                    var data = google.visualization.arrayToDataTable(<?php echo $name?>);
                    var options = {title: 'Doanh thu theo các mặt hàng'};

                    var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
                    chart.draw(data, options);
                }
                </script>
               </div>
                <body>      
                <center>    
               <div align=center id="chart_div" style="width: 900px; height: 500px;"></div>
                </center>
          </body>
               <table cellpadding='0' cellspacing='0' width='100%' border='0' class="table">

                    <tr bgcolor="Gainsboro" height='20'>
                        <td class="td"><p align="center"><b><?php echo $STT; ?></b>
                        </td>
                        <td class="td"><p align="center"><b><?php echo $group_name; ?></b>
                        </td>

                        <td class="td"><p align="center"><b><?php echo $Doanhthu; ?></b>
                        </td>
                    </tr>
                    <?php
                        $i = 0;
                       
                        foreach ($rows as $result)  
                        {
                           
                                $i=$i + 1; ?>
                                <tr height='20'>
                                <td class='td'><p align='center'><b><?php echo $i; ?></b>
                                </td>
                                <td class='td'><p align='center'><a href="<?php echo $result['href']; ?>" target="_blank">
                                            <b><?php echo $result['name']; ?></a></b>
                                </td>
                                <td class='td'><p align='center'><b><?php echo $result['amount'];?></b>
                                </td>
                        <?php } ?>
                                <tr height='20'>
                                <td class='td'><p align='center'><b><?php echo $i + 1; ?></b>
                                </td>
                                <td class='td'><p align='center'>
                                            <b><?php echo $text_total; ?></b>
                                </td>
                                <td class='td'><p align='center'><b><?php echo $total; ?></b>
                                </td>
               </table> 
          <?php } else { ?>
          <tr>
            <td class="center" colspan="6"><?php echo $text_no_results; ?></td>
          </tr>
          <?php } ?>
          </div>
      </div>
  </div>
  <?php echo $footer;?>